// Increase the space allocated for the background only application stack.
//
// Warning: SetApplLimit always sets the stack to at least as large as the
// default stack for the machine (8K on machines with original QuickDraw,
// 24K on machines with Color QuickDraw), so the application partition
// must be large enough to accommodate an appropriate stack and heap.
// Call this only once, at the beginning of the BOA.
//
// Another warning:
// Don't bother trying to set the stack size to something lower than 24K.
// If SetApplLimit is called to do this, it will silently lower ApplLimit
// to a 24K stack. (The limit is 8K on machines without Color QuickDraw.
// In this sample, we don't allow an increment less than 24K.)
OSErr IncreaseBOAStack (Size additionalStackSize)
{
OSErr retCode;
// Check that we aren't running with a corrupt heap. If we are,
// fix the problem. This was a bug with FBA's before System 7.5.5.
// With System Software later than 7.5.5, this "fix" is harmless.
myZone = GetZone ();
if (myZone->bkLim != LMGetHeapEnd ())
LMSetHeapEnd (myZone->bkLim);
// Increase the stack size by lowering the heap limit.
SetApplLimit ((Ptr) ((unsigned long) GetApplLimit () - additionalStackSize));
retCode = MemError ();
if (retCode == noErr)
MaxApplZone ();
return retCode;
}
|